Note: There are often multiple ways to answer each question.
Create a vector of integers from -5 to 10 (inclusive) and assign it to the variable x.
What is the sum of the elements of x? (This involves a function that we did not discuss in class. Google is your friend!)
Create a vector which consists of the first 10 multiples of 3 (i.e. 3, 6, …, 30) and assign it to the variable y.
What is the result of x + y? Why does R return this result?
What is the result of "1" + "2"? Why does R return this result?
What is the result of z <- c(1, 2, "3")? Why does R return this result?
Create a matrix using M <- matrix(1, 4, 5). What is the result, and why does R return this result?
Find the sum of the 3rd row of M.
Create the following list:
person <- list(name = "John Doe",
age = 26,
classes = c("ENG", "MAT", "SCI", "SPA", "MUS"))
What is the result of person$classes[2]? Why does R return this result?